<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath(); 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>"> 
<meta charset="UTF-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
<script type="text/javascript" src="js/jquery-1.8.0.js"></script> 
<script type="text/javascript">
	$(function(){
		$("table tr").mouseover(function(){
			$(this).css("background","#D3EAEF");
			$(this).siblings().css("background","white");
		});
		});
	function pagehtml(a) {
		window.location.href="AdminServlet.do?flag=listadmin&pageIndex="+a;
	}
</script>
</head>
<body>
	
	<div class ="div_title">
			<div class="div_titlename"> <img src="images/san_jiao.gif" ><span>用户角色管理列表</span></div>
			<div class="div_titleoper">
			</div>
	</div>
	
	 <table class="main_table" >
	       <tr>
	 					<th>账号</th> 	<th>状态</th>	<th>用户角色</th>  <th>最后更新日期</th> 	<th>操作</th>
	 		</tr>
	 		<c:forEach var="a" items="${adminList }" varStatus="st">
	 		<tr>
	 				
	 				<td>${a.adminName }</td>	
	 				<td>
	 					<c:choose>
				  			<c:when test="${a.state=='2'}">已锁定</c:when>
				  			<c:otherwise> </c:otherwise>
				  		</c:choose>				
	 				</td>	
	 				<td> <a title="${a.roleName}">
		 				<c:if test="${fn:length(a.roleName) > 10 }">
							${fn:substring(a.roleName,0,10)}...
						</c:if>
						<c:if test="${fn:length(a.roleName)  <= 10 }">
							${a.roleName}
						</c:if>
					</a></td>	
	 				
	 				<td><fmt:formatDate value="${a.editDate}" type="both" pattern="yyyy-MM-dd HH:mm"/></td>	
	 				<td>
	 				<c:choose>
				  			<c:when test="${a.state=='2'}"></c:when>
				  			<c:otherwise><a href="RoleServlet.do?flag=adminchange&amp;pageIndex=${page.pageIndex}&amp;id=${a.id}">角色分配</a> </c:otherwise>
				  	</c:choose>	
	 				</td>
	 		</tr>
	 		</c:forEach>
	</table>

	<div class="div_page" >
		<div class="div_page_left"> 共有 <label>${page.rowCount }</label> 条记录，当前第 <label>${page.pageIndex }</label> 页，共 <label>${page.pageCount }</label> 页	</div>		
		<div class="div_page_right" > 
			<form action="AdminServlet.do"  id="loginForm" method="get" >	 
			<c:choose>
				<c:when test="${page.hasPre }">
					<a href="javascript:pagehtml(1)">&nbsp;首页</a>
					<a href="javascript:pagehtml(${page.pageIndex-1 })">&nbsp;上一页</a>  &nbsp;  &nbsp;  &nbsp;  &nbsp;
				</c:when>
				<c:otherwise>
					&nbsp;首页
					&nbsp;上一页
				</c:otherwise>
			</c:choose>
			
			<c:choose>
				<c:when test="${page.hasNext }">
					<a href="javascript:pagehtml(${page.pageIndex+1 })">&nbsp;下一页</a>
					<a href="javascript:pagehtml(${page.pageCount })">&nbsp;尾页</a>
					
				</c:when>
				<c:otherwise>
					&nbsp;下一页
					&nbsp;尾页
				</c:otherwise>
			</c:choose>
		
			<input type="hidden" name="flag" value="manage">
			<button onclick="$('#loginForm').submit();">转到&nbsp;&nbsp;</button>
			<input type="text" name="pageIndex" id="pageIndex" value="${page.pageIndex}" oninput="inputnumber(this)"/> &nbsp;页
			</form>
		</div>			
	</div>
</body>
</html>